package state;

import java.io.IOException;

/**
 * Contains references to Global data, currently
 * only the logger and the debug flag.
 * 
 * @author Ian Doerr
 */
public class Globals {
    private static CustomLogger log = null;
    private static boolean debug = true;

    /**
     * initializes the logger using the given file name.
     * 
     * @param name
     * @throws IOException
     */
    public static void initLogger(String name) throws IOException
    {
        if (log == null)
        {
            synchronized (Globals.class)
            {
                if (log == null)
                {
                    log = new CustomLogger(name);
                }
            }
        }
    }

    /**
     * returns the current logger
     * 
     * @return
     */
    public static CustomLogger getLogger()
    {
        return log;
    }
    
    /**
     * Sets the debug flag
     * 
     * @param debug
     */
    public static void setDebug(boolean debug)
    {
    	Globals.debug = debug;
    }
    
    /**
     * Returns the debug flag
     * 
     * @return
     */
    public static boolean isDebug()
    {
    	return debug;
    }
}
